<template>
  <div :class="['breadcrumb_top_max', { eyebrow_navbar_max_hide: !sidebar.opened }]">
    <div class="maintoptext">
      <TagsView />
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { treeFindPath } from '@/utils/jcore/tree'
import TagsView from './TagsView/index.vue'
export default {
  name: 'Breadcrumb',
  components: {
    TagsView
  },
  data() {
    return {
      breadcrumbName: []
    }
  },
  computed: {
    ...mapGetters(['sidebar'])
  },
  created() {},
  watch: {
    $route(route) {
      this.getBreadcrumbName(route)
    }
  },
  mounted() {
    this.getBreadcrumbName(this.$route)
  },
  methods: {
    getBreadcrumbName(route) {
      let data = this.$store.getters
      let result = treeFindPath(
        data.menuList,
        (node) => {
          return node.meta.menuId == route.meta.menuId
        },
        { id: 'meta' }
      )
      let names = result.map((o) => o.title)
      // 切除第一个
      names.shift()
      this.breadcrumbName = names
    }
  }
}
</script>

<style lang="scss" scoped>
@import '~@/styles/variables.scss';

.maintoptext {
  height: $operationNavHeight;
  font-size: 14px;
  border-bottom: 1px solid $borderB;
  align-items: center;
  display: flex;
  box-sizing: border-box;
  background: linear-gradient(#fff, #f3f9ff);
}
</style>
